package alfred.camel;

import org.apache.camel.Endpoint;
import org.apache.camel.impl.DefaultComponent;
import org.zeromq.ZContext;
import org.zeromq.ZDispatcher;

import java.util.Map;

/**
 */
public class AlfredComponent extends DefaultComponent {
    private final static ZContext zmqContext = new ZContext();
    private final static ZDispatcher dispatcher = new ZDispatcher();
    private String clientsUri;
    private String workersUri;

    public AlfredComponent() {
    }

    public AlfredComponent(String clientsUri, String workersUri) {
        this.clientsUri = clientsUri;
        this.workersUri = workersUri;
    }

    @Override
    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
        AlfredEndpoint endpoint = new AlfredEndpoint(uri, remaining, this, zmqContext, dispatcher);
        setProperties(endpoint, parameters);
        return endpoint;
    }

    public static ZContext getZmqContext() {
        return zmqContext;
    }

    public static ZDispatcher getZmqDispatcher() {
        return dispatcher;
    }

    public String getClientsUri() {
        return clientsUri;
    }

    public String getWorkersUri() {
        return workersUri;
    }

    public void setClientsUri(String clientsUri) {
        this.clientsUri = clientsUri;
    }

    public void setWorkersUri(String workersUri) {
        this.workersUri = workersUri;
    }
}
